#!/bin/bash

# UDM API Server Demo Test Script
# Usage: ./test.sh [base_url]

BASE_URL=${1:-"http://localhost:81"}

echo "Testing UDM API Server Demo at $BASE_URL"
echo "=========================================="

# Test root endpoint
echo -e "\n1. Testing root endpoint..."
curl -s "$BASE_URL/" | jq '.'

# Test health check
echo -e "\n2. Testing health check..."
curl -s "$BASE_URL/health" | jq '.'

# Test MSISDN list
echo -e "\n3. Testing MSISDN list..."
curl -s "$BASE_URL/msisdns" | jq '.'

# Test predefined MSISDNs
echo -e "\n4. Testing predefined MSISDN: 8613764010195"
curl -s "$BASE_URL/service/user/UdmSubscription?number=8613764010195" | jq '.result.records[0] | {imsi, msisdn, regUdm, gprsLock, epsLock, gprsChargeGlobal}'

echo -e "\n5. Testing predefined MSISDN: 8613764010196"
curl -s "$BASE_URL/service/user/UdmSubscription?number=8613764010196" | jq '.result.records[0] | {imsi, msisdn, regUdm, gprsLock, epsLock, gprsChargeGlobal}'

echo -e "\n6. Testing predefined MSISDN: 8613764010197"
curl -s "$BASE_URL/service/user/UdmSubscription?number=8613764010197" | jq '.result.records[0] | {imsi, msisdn, regUdm, gprsLock, epsLock, gprsChargeGlobal}'

# Test random MSISDN
echo -e "\n7. Testing random MSISDN: 8613764010198"
curl -s "$BASE_URL/service/user/UdmSubscription?number=8613764010198" | jq '.result.records[0] | {imsi, msisdn, regUdm, gprsLock, epsLock, gprsChargeGlobal}'

# Test missing parameter
echo -e "\n8. Testing missing parameter..."
curl -s "$BASE_URL/service/user/UdmSubscription" | jq '.'

echo -e "\n=========================================="
echo "Testing completed!" 